/**
 * 3
 *  
 * @Author : roryrywang
 * @DateTime : 24-9-8 下午1:58
 */

#include <iostream>
#include <unordered_set>
#include <bitset>

using namespace std;

int f(int x) {
    return bitset<32>(x).count();
}

int g(int x) {
    int fx = f(x);
    int y = x + 1;
    while (f(y) != fx) {
        y++;
    }
    return y;
}

int main() {
    int n;
    cin >> n;
    unordered_set<int> set;
    for (int i = 0; i < n; ++i) {
        int num;
        cin >> num;
        set.insert(num);
    }

    int res = 0;
    for (int x: set) {
        int len = 1;
        int next = g(x);

        while (set.find(next) != set.end()) {
            len++;
            next = g(next);
        }

        res = max(res, len);
    }

    cout << res << endl;
    return 0;
}
